﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace PowerBooking.RSE.Utility.Helpers
{
    public class ExceptionHelper
    {
        private static object locker = new object();

        public static void WriteFileLog(Exception exception)
        {
            var logStringBuilder = new StringBuilder();
            logStringBuilder.AppendLine("===========================" + exception.Message);
            logStringBuilder.AppendLine("Time:" + DateTime.Now.ToString());
            logStringBuilder.AppendLine("Message:" + exception.Message);
            logStringBuilder.AppendLine("StackTrace:" + exception.StackTrace);
            logStringBuilder.AppendLine("Source:" + exception.Source);
            lock (locker)
            {
                File.AppendAllText(@"c:\workarea\log.txt", logStringBuilder.ToString());
            }
        }
    }
}
